﻿
' Klasse für die Verwaltung diverser System Properties. Ist so designt, das Später ev properties aus einem File einglesen werden könnten.
' Autor: Benjamin
Public Class PropertiesHandler
    Private Class Prop
        Public name As String
        Public value As String
    End Class

    Private Shared instance As PropertiesHandler = Nothing

    Private properties As List(Of Prop)

    Public Sub New()
        put("db.connection.string", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Zalia.accdb")
    End Sub

    Public Shared Function getInstance() As PropertiesHandler
        If IsNothing(instance) Then
            instance = New PropertiesHandler
        End If
        Return instance
    End Function

    Public Shared Function getValue(ByRef name As String) As String
        For Each p As Prop In getInstance().properties
            If p.name = name Then
                Return p.value
            End If
        Next
        Return Nothing
    End Function

    Public Sub put(ByRef name As String, ByRef value As String)
        Dim p As Prop = New Prop()
        p.name = name
        p.value = value
        properties.Add(p)
    End Sub
End Class